package com.dongdongkeji.wangwangsocial.ui.login.presenter;

import android.content.Context;

import com.dongdongkeji.base.api.ApiExecutor;
import com.dongdongkeji.base.api.ProgressObserver;
import com.dongdongkeji.base.mvp.BasePresenter;
import com.dongdongkeji.wangwangsocial.data.model.Account;
import com.dongdongkeji.wangwangsocial.data.repository.LoginRepository;
import com.dongdongkeji.wangwangsocial.ui.login.TestActivity;

import io.reactivex.disposables.CompositeDisposable;

/**
 * Author: ChenJing
 * Date: 2017-06-20 下午 5:06
 * Version: 1.0
 */

public class TestPresenter extends BasePresenter<TestActivity>{

    public TestPresenter(Context context, CompositeDisposable disposables) {
        super(context, disposables);
    }

    public void login(String phone, String pwd){
        LoginRepository loginRepository = new LoginRepository();
        ApiExecutor.execute(loginRepository.login(phone, pwd), new ProgressObserver<Account>(context, disposables) {
            @Override
            public void onNext(Account account) {
                getView().showResult(true);
            }

            @Override
            public void onError(int errorCode) {
                getView().showResult(false);
            }
        });
    }
}
